package com.xy;

import com.xy.article.WeaponCudgel;
import com.xy.article.WeaponHair;
import com.xy.creature.Person;
import com.xy.creature.Monster;
import com.xy.creature.MonsterSet;

import java.util.Scanner;
/**
 * @description:场景
 * @author: Xiang Yao
 * @date: Created in 2020/6/7
 */
public class Sense {
    private Person person= new Person() {
        public Room getCurrentRoom() {
            return null;
        }

        public void go(String word) {

        }

        public Monster[] getmonsters() {
            return new Monster[0];
        }
    };
    private Monster monster1= new Monster() {
        public Room getCurrentRoom() {
            return null;
        }

        public void setCurrentRoom(Room currentRoom) {

        }

        public int getHPvalue() {
            return 0;
        }

        public void setHPvalue(int HPvalue) {

        }

        public Monster[] getmonsters() {
            return new Monster[0];
        }
    };
    private Monster monster2= new Monster() {
        public Room getCurrentRoom() {
            return null;
        }

        public void setCurrentRoom(Room currentRoom) {

        }

        public int getHPvalue() {
            return 0;
        }

        public void setHPvalue(int HPvalue) {

        }

        public Monster[] getmonsters() {
            return new Monster[0];
        }
    };
    private Monster monster3= new Monster() {
        public Room getCurrentRoom() {
            return null;
        }

        public void setCurrentRoom(Room currentRoom) {

        }

        public int getHPvalue() {
            return 0;
        }

        public void setHPvalue(int HPvalue) {

        }

        public Monster[] getmonsters() {
            return new Monster[0];
        }
    };
    private MonsterSet monsterSet =new MonsterSet();
    Ui ui=new Ui();

    public void initSense(){
        initMonster();
        initPerson();
    }
    public void initPerson(){
        person.setId("01");
        person.setDescription("孙行者");
        person.setHPValue(200);
        person.setCurrentWeapon(new WeaponCudgel("w1", "如意金箍棒", -100) {
            @Override
            protected int getDamagaPoint() {
                return 0;
            }

            public String getDamagePoints() {
                return null;
            }
        });
    }
    public  void initMonster(){
        monster1.setId("m1");
        monster1.setDescription("哪吒");
        monster1.setHPValue(100);
        monster1.setCurrentWeapon(new WeaponHair("a1", "混天绫", -30) {
            @Override
            protected int getDamagaPoint() {
                return 0;
            }

            public String getDamagePoints() {
                return null;
            }
        });

        monster2.setId("m2");
        monster2.setDescription("托塔李天王");
        monster2.setHPValue(100);
        monster2.setCurrentWeapon(new WeaponCudgel("a2", "玲珑玉塔", -40) {
            @Override
            protected int getDamagaPoint() {
                return 0;
            }

            public String getDamagePoints() {
                return null;
            }
        });

        monster3.setId("m3");
        monster3.setDescription("二郎神杨戬");
        monster3.setHPValue(140);
        monster3.setCurrentWeapon(new WeaponHair("a3", "三尖两刃刀", -50) {
            @Override
            protected int getDamagaPoint() {
                return 0;
            }

            public String getDamagePoints() {
                return null;
            }
        });

        monsterSet.getMonsters().add((monster1));
        monsterSet.getMonsters().add(monster2);
        monsterSet.getMonsters().add(monster3);
    }

//    public boolean judgeSuccess() {
//        boolean flagPersonSuccess = true;
//
//        if (this.getPerson().getHPValue() <= 0) {
//            flagPersonSuccess = false;
//        }
//    }//判断胜负

    public void play(){
        Ui.displayStaus(this);


        Scanner in=new Scanner(System.in);
        while (true){
            //用户输入命令
            String command=in.nextLine();
            //分割命令行各个单元
            String[] cmdLineItems =command.split(" ");

            //chop bye help
            if(cmdLineItems[0].equals("bye")){
                Ui.displayBye();
                System.exit(0);
            }else if(cmdLineItems[0].equals(("help"))){
                Ui.displayHelpMsg();
            }else if(cmdLineItems[0].equals("chop")){
                this.getPerson().useArticle(getPerson().getCurrentWeapon(),
                        this.getMonsterSet().get(cmdLineItems[1]));
                ui.dispalyDamageMsg(this.getPerson(),this.getMonsterSet().get(cmdLineItems[1]));
                for(Monster item:this.getMonsterSet().getMonsters()){
                    if(1==Utils.randomMonsterChop(0, 2)){
                        item.useArticle(item.getCurrentWeapon(),this.getPerson());
                        ui.dispalyDamageMsg(item,this.getPerson());
                    }else {
                    }
                }

                //妖怪砍人
            }else {
                ui.displayErroCmdMsg();
            }
            Ui.displayStaus(this);
        }
    }

    private void getMonster() {
    }

    public Person getPerson() {
        return person;
    }

    public void setPerson(Person person) {
        this.person = person;
    }

    public Monster monster1() {
        return monster1;
    }

    public void setMonster1(Monster monster1) {
        this.monster1 = monster1;
    }

    public Monster getMonster2() {
        return monster2;
    }

    public void setMonster2(Monster monster2) {
        this.monster2= monster2;
    }

    public Monster getMonster3() {
        return monster3;
    }

    public void setMonster3(Monster monster3) {
        this.monster3 = monster3;
    }

    public MonsterSet getMonsterSet() {
        return monsterSet;
    }

    public void setMonsterSet(MonsterSet playingCardSet) {
        this.monsterSet = playingCardSet;
    }

    public Ui getUi() {
        return ui;
    }

    public void setUi(Ui ui) {
        this.ui = ui;
    }
}
